<?php /* COMPANIES $Id: vw_users.php,v 1.12 2005/04/08 13:41:51 gregorerhardt Exp $ */
##
##	Companies: View User sub-table
##
global $AppUI, $company_id;

$q  = new DBQuery;
$q->addTable('users');
$q->addQuery('user_id, user_username, contact_first_name, contact_last_name');
$q->addJoin('contacts', 'c', 'users.user_contact = contact_id');
$q->addWhere('contact_company = '.$company_id);
$q->addOrder('contact_last_name');

$s = '';
$total = 0;
if (!($rows = $q->loadList())) {
	$s .= '<tr class="padding"><td colspan="2">'.$AppUI->_('No data available').'<br/>'.$AppUI->getMsg().'</td></tr>';
} else {
	$total = count($rows);
	foreach ($rows as $row){
		$s .= '<tr class="second"><td>';
		$s .= '<a href="javascript:User('.$row['user_id'].').show()">'.$row['user_username'].'</a>';
		$s .= '<td>'.$row['contact_last_name'].", ".$row['contact_first_name'].'</td>';
		$s .= '</tr>';
	}
}
?>
<table border="0" cellpadding="7" cellspacing="0" width="100%" class="infopanel">
<tr>
	<td class="status">Total:</td>
	<td width="100%"><?=$total?>&nbsp;persons</td>
</tr>
</table>
<table width="100%" border=0 cellpadding="3" cellspacing="0" class="list">
<tr>
	<th><?=$AppUI->_( 'Username' )?></td>
	<th width="60%"><?=$AppUI->_( 'Full Name' )?></td>
</tr>
<?
	if (!$total)
		showEmptyRow(2, 'padding');
	else
		echo $s;
?>
</table>
